

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>nrgpy.read.sympro_txt &mdash; nrgpy 0.10.19 documentation</title>
  

  
  <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />

  
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script>
        <script src="../../../_static/jquery.js"></script>
        <script src="../../../_static/underscore.js"></script>
        <script src="../../../_static/doctools.js"></script>
    
    <script type="text/javascript" src="../../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../../genindex.html" />
    <link rel="search" title="Search" href="../../../search.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="../../../index.html" class="icon icon-home"> nrgpy
          

          
          </a>

          
            
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <!-- Local TOC -->
              <div class="local-toc"></div>
            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../../index.html">nrgpy</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          

















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../../../index.html" class="icon icon-home"></a> &raquo;</li>
        
          <li><a href="../../index.html">Module code</a> &raquo;</li>
        
      <li>nrgpy.read.sympro_txt</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <h1>Source code for nrgpy.read.sympro_txt</h1><div class="highlight"><pre>
<span></span><span class="kn">import</span> <span class="nn">datetime</span>
<span class="kn">from</span> <span class="nn">datetime</span> <span class="kn">import</span> <span class="n">datetime</span><span class="p">,</span> <span class="n">timedelta</span>
<span class="kn">from</span> <span class="nn">glob</span> <span class="kn">import</span> <span class="n">glob</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span>
<span class="kn">from</span> <span class="nn">nrgpy.utils.utilities</span> <span class="kn">import</span> <span class="n">check_platform</span><span class="p">,</span> <span class="n">windows_folder_path</span><span class="p">,</span> <span class="n">linux_folder_path</span><span class="p">,</span> <span class="n">draw_progress_bar</span><span class="p">,</span> <span class="n">date_check</span><span class="p">,</span> <span class="n">renamer</span>
<span class="kn">import</span> <span class="nn">traceback</span>


<div class="viewcode-block" id="sympro_txt_read"><a class="viewcode-back" href="../../../nrgpy.read.html#nrgpy.read.sympro_txt.sympro_txt_read">[docs]</a><span class="k">class</span> <span class="nc">sympro_txt_read</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filename</span><span class="o">=</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="n">out_file</span><span class="o">=</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="n">text_timestamps</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Class of pandas dataframes created from SymPRO standard txt output.</span>

<span class="sd">        If a filename is passed when calling class, the file is read in alone. Otherwise,</span>
<span class="sd">        and instance of the class is created, and the concat_txt function may be called to</span>
<span class="sd">        combine all txt files in a directory.</span>

<span class="sd">        filter may be used on any part of the filename, to combine a subset of text files in</span>
<span class="sd">        a directory.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        filename : str, optional</span>
<span class="sd">            path to filename</span>
<span class="sd">        out_file : str, optional</span>
<span class="sd">            path to outputted file</span>
<span class="sd">        text_timestamps : boolean</span>
<span class="sd">            set to True for text timestamps</span>

<span class="sd">        Returns</span>
<span class="sd">        ---------</span>
<span class="sd">        ch_info : obj</span>
<span class="sd">            pandas dataframe of ch_list (below) pulled out of file with sympro_txt_read.arrange_ch_info()</span>
<span class="sd">        ch_list : list</span>
<span class="sd">            list of channel info; can be converted to json w/ import json ... json.dumps(fut.ch_info)</span>
<span class="sd">        data : obj</span>
<span class="sd">            pandas dataframe of all data</span>
<span class="sd">        head : obj</span>
<span class="sd">            lines at the top of the txt file..., used when rebuilding timeshifted files</span>
<span class="sd">        site_info : obj</span>
<span class="sd">            pandas dataframe of site information</span>
<span class="sd">        logger_sn : str</span>
<span class="sd">        ipack_sn : str</span>
<span class="sd">        logger_type : str</span>
<span class="sd">        ipack_type : str</span>
<span class="sd">        latitude : float</span>
<span class="sd">        longitude : float</span>
<span class="sd">        elevation : int</span>
<span class="sd">        site_number : str</span>
<span class="sd">        site_description : str</span>
<span class="sd">        start_date : str</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">filename</span> <span class="o">=</span> <span class="n">filename</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">text_timestamps</span> <span class="o">=</span> <span class="n">text_timestamps</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">out_file</span> <span class="o">=</span> <span class="n">out_file</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">reader_type</span> <span class="o">=</span> <span class="s2">&quot;SymphoniePRO&quot;</span>

        <span class="k">if</span> <span class="n">out_file</span> <span class="o">==</span> <span class="s2">&quot;&quot;</span><span class="p">:</span>
            <span class="n">out_file</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">today</span><span class="p">()</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s2">&quot;%Y-%m-</span><span class="si">%d</span><span class="s2">&quot;</span><span class="p">)</span> <span class="o">+</span> <span class="s2">&quot;_SymPRO.txt&quot;</span>

        <span class="k">if</span> <span class="s1">&#39;ch_details&#39;</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">ch_details</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;ch_details&#39;</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">ch_details</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="k">if</span> <span class="s1">&#39;site_details&#39;</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">site_details</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;site_details&#39;</span><span class="p">)</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">filename</span><span class="p">:</span>
            <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span>
            <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">filename</span><span class="p">)</span> <span class="k">as</span> <span class="n">infile</span><span class="p">:</span>
                <span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">infile</span><span class="p">:</span>
                    <span class="k">if</span> <span class="n">line</span> <span class="o">==</span> <span class="s2">&quot;Data</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">:</span>
                        <span class="k">break</span>
                    <span class="k">else</span><span class="p">:</span>
                        <span class="n">i</span> <span class="o">=</span> <span class="n">i</span> <span class="o">+</span> <span class="mi">1</span>
            <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">filename</span><span class="p">)</span> <span class="k">as</span> <span class="n">myfile</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">head</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span><span class="o">.</span><span class="n">join</span><span class="p">([</span><span class="nb">next</span><span class="p">(</span><span class="n">myfile</span><span class="p">)</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">2</span><span class="p">)])</span>

            <span class="n">header_len</span> <span class="o">=</span> <span class="n">i</span> <span class="o">+</span> <span class="mi">1</span>
            <span class="n">read_len</span> <span class="o">=</span> <span class="n">header_len</span> <span class="o">-</span> <span class="mi">5</span>

            <span class="bp">self</span><span class="o">.</span><span class="n">site_info</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">read_csv</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">filename</span><span class="p">,</span> <span class="n">skiprows</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">&quot;</span><span class="se">\t</span><span class="s2">&quot;</span><span class="p">,</span>
                <span class="n">index_col</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">nrows</span><span class="o">=</span><span class="n">read_len</span><span class="p">,</span>
                <span class="n">usecols</span><span class="o">=</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">],</span> <span class="n">header</span><span class="o">=</span><span class="kc">None</span>
            <span class="p">)</span>

            <span class="bp">self</span><span class="o">.</span><span class="n">site_info</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">site_info</span><span class="o">.</span><span class="n">iloc</span><span class="p">[:</span><span class="bp">self</span><span class="o">.</span><span class="n">site_info</span><span class="o">.</span><span class="n">loc</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">site_info</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s1">&#39;Data&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">index</span><span class="o">.</span><span class="n">tolist</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span><span class="o">+</span><span class="mi">1</span><span class="p">]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">read_csv</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">filename</span><span class="p">,</span> <span class="n">skiprows</span><span class="o">=</span><span class="n">header_len</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">&quot;</span><span class="se">\t</span><span class="s2">&quot;</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="s1">&#39;iso-8859-1&#39;</span><span class="p">)</span>
            <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">text_timestamps</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;Timestamp&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">to_datetime</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;Timestamp&#39;</span><span class="p">])</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">first_timestamp</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">iloc</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="s1">&#39;Timestamp&#39;</span><span class="p">]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">arrange_ch_info</span><span class="p">()</span>
            <span class="k">if</span> <span class="ow">not</span> <span class="nb">hasattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="s1">&#39;site_details&#39;</span><span class="p">):</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">format_site_data</span><span class="p">()</span>

    <span class="k">def</span> <span class="fm">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="s1">&#39;&lt;class </span><span class="si">{}</span><span class="s1">: </span><span class="si">{}</span><span class="s1"> &gt;&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">filename</span><span class="p">)</span>

<div class="viewcode-block" id="sympro_txt_read.arrange_ch_info"><a class="viewcode-back" href="../../../nrgpy.read.html#nrgpy.read.sympro_txt.sympro_txt_read.arrange_ch_info">[docs]</a>    <span class="k">def</span> <span class="nf">arrange_ch_info</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;creates ch_info dataframe and ch_list array&quot;&quot;&quot;</span>
        <span class="n">array</span> <span class="o">=</span> <span class="p">[</span>
            <span class="s1">&#39;Channel:&#39;</span><span class="p">,</span>
            <span class="s1">&#39;Export Channel:&#39;</span><span class="p">,</span>
            <span class="s1">&#39;Effective Date:&#39;</span><span class="p">,</span>
            <span class="s1">&#39;Type:&#39;</span><span class="p">,</span>
            <span class="s1">&#39;Description:&#39;</span><span class="p">,</span>
            <span class="s1">&#39;Serial Number:&#39;</span><span class="p">,</span>
            <span class="s1">&#39;Height:&#39;</span><span class="p">,</span>
            <span class="s1">&#39;Bearing:&#39;</span><span class="p">,</span>
            <span class="s1">&#39;Scale Factor:&#39;</span><span class="p">,</span>
            <span class="s1">&#39;Offset:&#39;</span><span class="p">,</span>
            <span class="s1">&#39;Units:&#39;</span>
        <span class="p">]</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">ch_details</span><span class="p">:</span>
            <span class="n">array</span> <span class="o">+=</span> <span class="p">[</span>
                <span class="s1">&#39;P-SCM Type:&#39;</span><span class="p">,</span>
                <span class="s1">&#39;Total Direction Offset:&#39;</span><span class="p">,</span>
                <span class="s1">&#39;Dead Band East:&#39;</span><span class="p">,</span>
                <span class="s1">&#39;Dead Band West:&#39;</span><span class="p">,</span>
                <span class="s1">&#39;Excitation Mode:&#39;</span><span class="p">,</span>
                <span class="s1">&#39;Excitation Value:&#39;</span><span class="p">,</span>
                <span class="s1">&#39;Data Logging Mode:&#39;</span>
            <span class="p">]</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">pass</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">array</span> <span class="o">=</span> <span class="n">array</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">ch_info</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">()</span>
        <span class="n">ch_data</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="n">ch_list</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">ch_details</span> <span class="o">=</span> <span class="mi">0</span>

        <span class="k">for</span> <span class="n">row</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">site_info</span><span class="o">.</span><span class="n">loc</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">site_info</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">isin</span><span class="p">(</span><span class="n">array</span><span class="p">)]</span><span class="o">.</span><span class="n">iterrows</span><span class="p">():</span>

            <span class="k">if</span> <span class="n">row</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="n">array</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="ow">and</span> <span class="n">ch_details</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>  <span class="c1"># start channel data read</span>
                <span class="n">ch_details</span> <span class="o">=</span> <span class="mi">1</span>
                <span class="n">ch_data</span><span class="p">[</span><span class="n">row</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="mi">0</span><span class="p">]]</span> <span class="o">=</span> <span class="n">row</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span>

            <span class="k">elif</span> <span class="n">row</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="n">array</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="ow">and</span> <span class="n">ch_details</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>  <span class="c1"># close channel, start new data read</span>
                <span class="n">ch_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">ch_data</span><span class="p">)</span>
                <span class="n">ch_data</span> <span class="o">=</span> <span class="p">{}</span>
                <span class="n">ch_data</span><span class="p">[</span><span class="n">row</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="mi">0</span><span class="p">]]</span> <span class="o">=</span> <span class="n">row</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span>

            <span class="k">elif</span> <span class="n">row</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="ow">in</span> <span class="nb">str</span><span class="p">(</span><span class="n">array</span><span class="p">):</span>
                <span class="n">ch_data</span><span class="p">[</span><span class="n">row</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="mi">0</span><span class="p">]]</span> <span class="o">=</span> <span class="n">row</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span>

        <span class="n">ch_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">ch_data</span><span class="p">)</span>  <span class="c1"># last channel&#39;s data</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">ch_list</span> <span class="o">=</span> <span class="n">ch_list</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">ch_info</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">ch_info</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">ch_list</span><span class="p">)</span>

        <span class="k">return</span> <span class="bp">self</span></div>

<div class="viewcode-block" id="sympro_txt_read.format_site_data"><a class="viewcode-back" href="../../../nrgpy.read.html#nrgpy.read.sympro_txt.sympro_txt_read.format_site_data">[docs]</a>    <span class="k">def</span> <span class="nf">format_site_data</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;take txt header to create oject data&quot;&quot;&quot;</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">Site_info</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">site_info</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_site_info</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">Site_info</span><span class="o">.</span><span class="n">T</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_site_info</span><span class="o">.</span><span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_site_info</span><span class="o">.</span><span class="n">iloc</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_site_info</span><span class="o">.</span><span class="n">columns</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_site_info</span><span class="o">.</span><span class="n">iloc</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_site_info</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_site_info</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span>

            <span class="n">width</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_site_info</span><span class="o">.</span><span class="n">columns</span><span class="o">.</span><span class="n">values</span><span class="p">)</span><span class="o">.</span><span class="n">index</span><span class="p">(</span><span class="s1">&#39;Sensor History&#39;</span><span class="p">)</span>

            <span class="bp">self</span><span class="o">.</span><span class="n">_site_info</span><span class="o">.</span><span class="n">rename</span><span class="p">(</span><span class="n">columns</span><span class="o">=</span><span class="n">renamer</span><span class="p">(),</span> <span class="n">inplace</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_site_info</span><span class="o">.</span><span class="n">drop</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_site_info</span><span class="o">.</span><span class="n">iloc</span><span class="p">[:,</span> <span class="n">width</span><span class="p">:</span><span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_site_info</span><span class="o">.</span><span class="n">columns</span><span class="p">)],</span> <span class="n">axis</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">inplace</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">errors</span><span class="o">=</span><span class="s1">&#39;ignore&#39;</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_site_info</span><span class="o">.</span><span class="n">columns</span> <span class="o">=</span> <span class="p">[</span><span class="nb">str</span><span class="p">(</span><span class="n">col</span><span class="p">)</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">&#39;:&#39;</span><span class="p">,</span><span class="s1">&#39;&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_site_info</span><span class="o">.</span><span class="n">columns</span><span class="p">]</span>

            <span class="bp">self</span><span class="o">.</span><span class="n">latitude</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_site_info</span><span class="p">[</span><span class="s1">&#39;Latitude&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">values</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">longitude</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_site_info</span><span class="p">[</span><span class="s1">&#39;Longitude&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">values</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">elevation</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_site_info</span><span class="p">[</span><span class="s1">&#39;Elevation&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">values</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">location</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_site_info</span><span class="p">[</span><span class="s1">&#39;Location&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">values</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">site_number</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_site_info</span><span class="p">[</span><span class="s1">&#39;Site Number&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">values</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">site_description</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_site_info</span><span class="p">[</span><span class="s1">&#39;Site Description&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">values</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>

            <span class="bp">self</span><span class="o">.</span><span class="n">logger_sn</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_site_info</span><span class="p">[</span><span class="s1">&#39;Serial Number&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">values</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">ipack_sn</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_site_info</span><span class="p">[</span><span class="s1">&#39;Serial Number_1&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">values</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">logger_type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_site_info</span><span class="p">[</span><span class="s1">&#39;Model&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">values</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">ipack_type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_site_info</span><span class="p">[</span><span class="s1">&#39;Model_1&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">values</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">time_zone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_site_info</span><span class="p">[</span><span class="s1">&#39;Time Zone&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">values</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>

        <span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">e</span> <span class="o">=</span> <span class="n">e</span>
            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Warning: error processing site_info: </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">e</span><span class="p">))</span></div>

<div class="viewcode-block" id="sympro_txt_read.concat_txt"><a class="viewcode-back" href="../../../nrgpy.read.html#nrgpy.read.sympro_txt.sympro_txt_read.concat_txt">[docs]</a>    <span class="k">def</span> <span class="nf">concat_txt</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">txt_dir</span><span class="o">=</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="n">file_type</span><span class="o">=</span><span class="s1">&#39;meas&#39;</span><span class="p">,</span> <span class="n">file_filter</span><span class="o">=</span><span class="s1">&#39;&#39;</span><span class="p">,</span>
                    <span class="n">filter2</span><span class="o">=</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="n">start_date</span><span class="o">=</span><span class="s1">&#39;1970-01-01&#39;</span><span class="p">,</span> <span class="n">end_date</span><span class="o">=</span><span class="s1">&#39;2150-12-31&#39;</span><span class="p">,</span>
                    <span class="n">ch_details</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">output_txt</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">out_file</span><span class="o">=</span><span class="s1">&#39;&#39;</span><span class="p">,</span>
                    <span class="n">progress_bar</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Will concatenate all text files in the txt_dir</span>

<span class="sd">        files must match the site_filter argument. Note these are both blank by default.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        txt_dir : str</span>
<span class="sd">            directory holding txt files</span>
<span class="sd">        file_type : str</span>
<span class="sd">            type of export (meas, event, comm, sample, etc...)</span>
<span class="sd">        file_filter : str</span>
<span class="sd">            text filter for txt files, like site number, etc.</span>
<span class="sd">        filter2 : str</span>
<span class="sd">            secondary text filter</span>
<span class="sd">        start_date : str</span>
<span class="sd">            for filtering files to concat based on date &quot;YYYY-mm-dd&quot;</span>
<span class="sd">        end_date : str</span>
<span class="sd">            for filtering files to concat based on date &quot;YYYY-mm-dd&quot;</span>
<span class="sd">        ch_details : bool</span>
<span class="sd">            show additional info in ch_info dataframe</span>
<span class="sd">        output_txt : bool</span>
<span class="sd">            create a txt output of data df</span>
<span class="sd">        out_file : str</span>
<span class="sd">            filename to write data dataframe too if output_txt = True</span>
<span class="sd">        progress_bar : bool</span>
<span class="sd">            show bar on concat [True] or list of files [False]</span>

<span class="sd">        Returns</span>
<span class="sd">        ---------</span>
<span class="sd">        ch_info : obj</span>
<span class="sd">            pandas dataframe of ch_list (below) pulled out of file with sympro_txt_read.arrange_ch_info()</span>
<span class="sd">        ch_list : list</span>
<span class="sd">            list of channel info; can be converted to json w/ import json ... json.dumps(fut.ch_info)</span>
<span class="sd">        data : obj</span>
<span class="sd">            pandas dataframe of all data</span>
<span class="sd">        head : obj</span>
<span class="sd">            lines at the top of the txt file..., used when rebuilding timeshifted files</span>
<span class="sd">        site_info : obj</span>
<span class="sd">            pandas dataframe of site information</span>
<span class="sd">        logger_sn : str</span>
<span class="sd">        ipack_sn : str</span>
<span class="sd">        logger_type : str</span>
<span class="sd">        ipack_type : str</span>
<span class="sd">        latitude : float</span>
<span class="sd">        longitude : float</span>
<span class="sd">        elevation : int</span>
<span class="sd">        site_number : str</span>
<span class="sd">        site_description : str</span>
<span class="sd">        start_date : str</span>
<span class="sd">        txt_file_names : list</span>
<span class="sd">            list of files included in concatenation</span>

<span class="sd">        Examples</span>
<span class="sd">        --------</span>
<span class="sd">        Read files into nrgpy reader object</span>

<span class="sd">        &gt;&gt;&gt; import nrgpy</span>
<span class="sd">        &gt;&gt;&gt; reader = nrgpy.sympro_txt_read()</span>
<span class="sd">        &gt;&gt;&gt; reader.concat_txt(</span>
<span class="sd">                txt_dir=&#39;/path/to/txt/files/&#39;,</span>
<span class="sd">                file_filter=&#39;123456&#39;, # site 123456</span>
<span class="sd">                start_date=&#39;2020-01-01&#39;,</span>
<span class="sd">                end_date=&#39;2020-01-31&#39;,</span>
<span class="sd">            )</span>
<span class="sd">        Time elapsed: 2 s | 33 / 33 [=============================================] 100%</span>
<span class="sd">        Queue processed</span>
<span class="sd">        &gt;&gt;&gt; reader.logger_sn</span>
<span class="sd">        &#39;820600019&#39;</span>
<span class="sd">        &gt;&gt;&gt; reader.ch_info</span>
<span class="sd">         	Bearing: 	Channel: 	Description: 	Effective Date: 	Height: 	Offset: 	Scale Factor: 	Serial Number: 	Type: 	Units:</span>
<span class="sd">        0 	50.00 	    1 	        NRG S1 	        2020-01-31 00:00:00 	33.00 	0.13900 	0.09350 	    94120000059 	Anemometer 	m/s</span>
<span class="sd">        1 	230.00 	    2 	        NRG S1 	        2020-01-31 00:00:00 	0.00 	0.13900 	0.09350 	    94120000058 	Anemometer 	m/s</span>
<span class="sd">        2 	50.00 	    3 	        NRG S1 	        2020-01-31 00:00:00 	22.00 	0.13900 	0.09350 	    94120000057 	Anemometer 	m/s</span>
<span class="sd">        3 	230.00 	    4 	        NRG 40C Anem 	2020-01-31 00:00:00 	22.00 	0.35000 	0.76500 	    179500324860 	Anemometer 	m/s</span>
<span class="sd">        4 	50.00 	    5 	        NRG 40C Anem 	2020-01-31 00:00:00 	12.00 	0.35000 	0.76500 	    179500324859 	Anemometer 	m/s</span>
<span class="sd">        5 	230.00 	    6 	        NRG S1 	        2020-01-31 00:00:00 	12.00 	0.13900 	0.09350 	    94120000056 	Anemometer 	m/s</span>
<span class="sd">        6 	320.00 	    13 	        NRG 200M Vane 	2020-01-31 00:00:00 	32.00 	-1.46020 	147.91100 	    10700000125 	Vane 	        Deg</span>
<span class="sd">        7 	320.00 	    14 	        NRG 200M Vane 	2020-01-31 00:00:00 	21.00 	-1.46020 	147.91100 	    10700000124 	Vane 	        Deg</span>
<span class="sd">        8 	0.00 	    15 	        NRG T60 Temp 	2020-01-31 00:00:00 	34.00 	-40.85550 	44.74360 	    9400000705          Analog          C</span>
<span class="sd">        9 	0.00 	    16 	        NRG T60 Temp 	2020-01-31 00:00:00 	2.00 	-40.85550 	44.74360 	    9400000xxx          Analog          C</span>
<span class="sd">        10 	0.00 	    17 	        NRG RH5X Humi 	2020-01-31 00:00:00 	0.00 	0.00000 	20.00000 	    NaN 	        Analog          %RH</span>
<span class="sd">        11 	0.00 	    20 	        NRG BP60 Baro 	2020-01-31 00:00:00 	0.00 	495.27700 	243.91400 	    NaN 	        Analog          hPa</span>
<span class="sd">        12 	0.00 	    21 	        NRG BP60 Baro 	2020-01-31 00:00:00 	2.00 	495.04400 	244.23900 	    9396FT1937          Analog  	hPa</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="s1">&#39;site_filter&#39;</span> <span class="ow">in</span> <span class="n">kwargs</span> <span class="ow">and</span> <span class="n">file_filter</span> <span class="o">==</span> <span class="s1">&#39;&#39;</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">file_filter</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;site_filter&#39;</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">file_filter</span> <span class="o">=</span> <span class="n">file_filter</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">ch_details</span> <span class="o">=</span> <span class="n">ch_details</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">start_date</span> <span class="o">=</span> <span class="n">start_date</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">end_date</span> <span class="o">=</span> <span class="n">end_date</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">filter2</span> <span class="o">=</span> <span class="n">filter2</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">file_type</span> <span class="o">=</span> <span class="n">file_type</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">txt_file_names</span> <span class="o">=</span> <span class="p">[]</span>

        <span class="k">if</span> <span class="n">check_platform</span><span class="p">()</span> <span class="o">==</span> <span class="s1">&#39;win32&#39;</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">txt_dir</span> <span class="o">=</span> <span class="n">windows_folder_path</span><span class="p">(</span><span class="n">txt_dir</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">txt_dir</span> <span class="o">=</span> <span class="n">linux_folder_path</span><span class="p">(</span><span class="n">txt_dir</span><span class="p">)</span>

        <span class="n">first_file</span> <span class="o">=</span> <span class="kc">True</span>

        <span class="n">files</span> <span class="o">=</span> <span class="p">[</span>
            <span class="n">f</span> <span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">glob</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">txt_dir</span> <span class="o">+</span> <span class="s1">&#39;*.txt&#39;</span><span class="p">))</span>\
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">file_filter</span> <span class="ow">in</span> <span class="n">f</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">filter2</span> <span class="ow">in</span> <span class="n">f</span>\
            <span class="ow">and</span> <span class="n">date_check</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">start_date</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">end_date</span><span class="p">,</span> <span class="n">f</span><span class="p">)</span>
        <span class="p">]</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">file_count</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">files</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">pad</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">file_count</span><span class="p">))</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">counter</span> <span class="o">=</span> <span class="mi">1</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">start_time</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">now</span><span class="p">()</span>

        <span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">files</span><span class="p">:</span>

            <span class="k">if</span> <span class="n">progress_bar</span><span class="p">:</span>
                <span class="n">draw_progress_bar</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">counter</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">file_count</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">start_time</span><span class="p">)</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Adding </span><span class="si">{0}</span><span class="s2">/</span><span class="si">{1}</span><span class="s2"> ... </span><span class="si">{2}</span><span class="s2"> ... &quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">counter</span><span class="p">)</span><span class="o">.</span><span class="n">rjust</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">pad</span><span class="p">),</span><span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">file_count</span><span class="p">)</span><span class="o">.</span><span class="n">ljust</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">pad</span><span class="p">),</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">basename</span><span class="p">(</span><span class="n">f</span><span class="p">)),</span> <span class="n">end</span><span class="o">=</span><span class="s2">&quot;&quot;</span><span class="p">,</span> <span class="n">flush</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>

            <span class="k">if</span> <span class="n">first_file</span> <span class="o">==</span> <span class="kc">True</span><span class="p">:</span>
                <span class="n">first_file</span> <span class="o">=</span> <span class="kc">False</span>

                <span class="k">try</span><span class="p">:</span>
                    <span class="n">base</span> <span class="o">=</span> <span class="n">sympro_txt_read</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">text_timestamps</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">text_timestamps</span><span class="p">)</span>
                    <span class="k">if</span> <span class="n">progress_bar</span> <span class="o">!=</span> <span class="kc">True</span><span class="p">:</span> <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;[OK]&quot;</span><span class="p">)</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">txt_file_names</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">basename</span><span class="p">(</span><span class="n">f</span><span class="p">))</span>
                <span class="k">except</span> <span class="ne">IndexError</span><span class="p">:</span>
                    <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Only standard SymPRO headertypes accepted&#39;</span><span class="p">)</span>
                    <span class="k">break</span>
                <span class="k">except</span><span class="p">:</span>
                    <span class="k">if</span> <span class="n">progress_bar</span> <span class="o">!=</span> <span class="kc">True</span><span class="p">:</span> <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;[FAILED]&quot;</span><span class="p">)</span>
                    <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;could not concat </span><span class="si">{0}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">basename</span><span class="p">(</span><span class="n">f</span><span class="p">)))</span>
                    <span class="k">pass</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">file_path</span> <span class="o">=</span> <span class="n">f</span>

                <span class="k">try</span><span class="p">:</span>
                    <span class="n">s</span> <span class="o">=</span> <span class="n">sympro_txt_read</span><span class="p">(</span>
                        <span class="n">file_path</span><span class="p">,</span>
                        <span class="n">ch_details</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ch_details</span><span class="p">,</span>
                        <span class="n">text_timestamps</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">text_timestamps</span><span class="p">,</span>
                        <span class="n">site_details</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
                    <span class="p">)</span>
                    <span class="n">base</span><span class="o">.</span><span class="n">data</span> <span class="o">=</span> <span class="n">base</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">s</span><span class="o">.</span><span class="n">data</span><span class="p">,</span> <span class="n">sort</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
                    <span class="k">if</span> <span class="n">progress_bar</span> <span class="o">!=</span> <span class="kc">True</span><span class="p">:</span> <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;[OK]&quot;</span><span class="p">)</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">txt_file_names</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">basename</span><span class="p">(</span><span class="n">f</span><span class="p">))</span>

                <span class="k">except</span><span class="p">:</span>
                    <span class="k">if</span> <span class="n">progress_bar</span> <span class="o">!=</span> <span class="kc">True</span><span class="p">:</span> <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;[FAILED]&quot;</span><span class="p">)</span>
                    <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;could not concat </span><span class="si">{0}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">basename</span><span class="p">(</span><span class="n">f</span><span class="p">)))</span>
                    <span class="k">pass</span>

            <span class="bp">self</span><span class="o">.</span><span class="n">counter</span> <span class="o">+=</span> <span class="mi">1</span>

        <span class="k">if</span> <span class="n">out_file</span> <span class="o">!=</span> <span class="s2">&quot;&quot;</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">out_file</span> <span class="o">=</span> <span class="n">out_file</span>

        <span class="k">if</span> <span class="n">output_txt</span> <span class="o">==</span> <span class="kc">True</span><span class="p">:</span>
            <span class="n">base</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">to_csv</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">txt_dir</span><span class="p">,</span> <span class="n">out_file</span><span class="p">),</span> <span class="n">sep</span><span class="o">=</span><span class="s1">&#39;,&#39;</span><span class="p">,</span> <span class="n">index</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>

        <span class="k">try</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">ch_info</span> <span class="o">=</span> <span class="n">s</span><span class="o">.</span><span class="n">ch_info</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">ch_list</span> <span class="o">=</span> <span class="n">s</span><span class="o">.</span><span class="n">ch_list</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">array</span> <span class="o">=</span> <span class="n">s</span><span class="o">.</span><span class="n">array</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span> <span class="o">=</span> <span class="n">base</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">drop_duplicates</span><span class="p">(</span><span class="n">subset</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;Timestamp&#39;</span><span class="p">],</span> <span class="n">keep</span><span class="o">=</span><span class="s1">&#39;first&#39;</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">reset_index</span><span class="p">(</span><span class="n">drop</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span><span class="n">inplace</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">head</span> <span class="o">=</span> <span class="n">s</span><span class="o">.</span><span class="n">head</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">site_info</span> <span class="o">=</span> <span class="n">s</span><span class="o">.</span><span class="n">site_info</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">format_site_data</span><span class="p">()</span>
            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">)</span>

        <span class="k">except</span> <span class="ne">UnboundLocalError</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;No files match to contatenate.&quot;</span><span class="p">)</span>
            <span class="k">return</span> <span class="kc">None</span></div>



<div class="viewcode-block" id="sympro_txt_read.select_channels_for_reformat"><a class="viewcode-back" href="../../../nrgpy.read.html#nrgpy.read.sympro_txt.sympro_txt_read.select_channels_for_reformat">[docs]</a>    <span class="k">def</span> <span class="nf">select_channels_for_reformat</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">epe</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">soiling</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;determines which of the channel headers fit those required for post-processing for either</span>

<span class="sd">            a. EPE formatting</span>
<span class="sd">            b. soiling ratio calculation</span>

<span class="sd">        Note that this formatting requires the the channel headers to be full (requires</span>
<span class="sd">        Local export of text files, as of 0.1.8.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="c1"># for EPE formatting</span>
        <span class="n">ch_anem</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;Anem&#39;</span><span class="p">,</span><span class="s1">&#39;Anemometer&#39;</span><span class="p">,</span><span class="s1">&#39;anem&#39;</span><span class="p">,</span><span class="s1">&#39;anemometer&#39;</span><span class="p">,</span><span class="s1">&#39;Anemômetro&#39;</span><span class="p">,</span><span class="s1">&#39;anemômetro&#39;</span><span class="p">]</span>
        <span class="n">ch_vane</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;Vane&#39;</span><span class="p">,</span><span class="s1">&#39;vane&#39;</span><span class="p">,</span><span class="s1">&#39;Direction&#39;</span><span class="p">,</span><span class="s1">&#39;direction&#39;</span><span class="p">,</span><span class="s1">&#39;Veleta&#39;</span><span class="p">,</span><span class="s1">&#39;veleta&#39;</span><span class="p">,</span><span class="s1">&#39;Direção&#39;</span><span class="p">,</span><span class="s1">&#39;direção&#39;</span><span class="p">,</span><span class="s1">&#39;Vane w/Offset&#39;</span><span class="p">]</span>
        <span class="n">ch_baro</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;mb&#39;</span><span class="p">,</span><span class="s1">&#39;hpa&#39;</span><span class="p">,</span><span class="s1">&#39;hPa&#39;</span><span class="p">,</span><span class="s1">&#39;millibar&#39;</span><span class="p">,</span><span class="s1">&#39;kPa&#39;</span><span class="p">,</span> <span class="s1">&#39;baro&#39;</span><span class="p">,</span> <span class="s1">&#39;Baro&#39;</span><span class="p">]</span>
        <span class="n">ch_relh</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;%RH&#39;</span><span class="p">,</span><span class="s1">&#39;</span><span class="si">%r</span><span class="s1">h&#39;</span><span class="p">,</span><span class="s1">&#39;RH&#39;</span><span class="p">,</span><span class="s1">&#39;rh&#39;</span><span class="p">]</span>
        <span class="n">ch_temp</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;C&#39;</span><span class="p">,</span><span class="s1">&#39;c&#39;</span><span class="p">,</span><span class="s1">&#39;?C&#39;</span><span class="p">,</span><span class="s1">&#39;Temp&#39;</span><span class="p">,</span><span class="s1">&#39;deg c&#39;</span><span class="p">,</span><span class="s1">&#39;deg f&#39;</span><span class="p">,</span><span class="s1">&#39;temp&#39;</span><span class="p">]</span>

        <span class="c1"># for soiling station</span>
        <span class="n">ch_I_units</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;amps&#39;</span><span class="p">,</span><span class="s1">&#39;amperes&#39;</span><span class="p">,</span><span class="s1">&#39;a&#39;</span><span class="p">,</span><span class="s1">&#39;current&#39;</span><span class="p">]</span>
        <span class="n">ch_shunt_desc</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;shunt&#39;</span><span class="p">,</span><span class="s1">&#39;isc&#39;</span><span class="p">,</span><span class="s1">&#39;current&#39;</span><span class="p">]</span>
        <span class="n">ch_clean_desc</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;clean&#39;</span><span class="p">]</span>
        <span class="n">ch_soiled_desc</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;soil&#39;</span><span class="p">,</span><span class="s1">&#39;soiled&#39;</span><span class="p">,</span><span class="s1">&#39;dirty&#39;</span><span class="p">]</span>
        <span class="n">ch_PV_temp</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;pv&#39;</span><span class="p">,</span><span class="s1">&#39;panel&#39;</span><span class="p">]</span>

        <span class="k">if</span> <span class="n">epe</span> <span class="o">==</span> <span class="kc">True</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">anem1</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">ch_info</span><span class="o">.</span><span class="n">loc</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">ch_info</span><span class="p">[</span><span class="s1">&#39;Type:&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">isin</span><span class="p">(</span><span class="n">ch_anem</span><span class="p">)]</span><span class="o">.</span><span class="n">sort_values</span><span class="p">([</span><span class="s1">&#39;Height:&#39;</span><span class="p">],</span><span class="n">ascending</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span><span class="o">.</span><span class="n">iloc</span><span class="p">[[</span><span class="mi">0</span><span class="p">]]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">anem2</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">ch_info</span><span class="o">.</span><span class="n">loc</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">ch_info</span><span class="p">[</span><span class="s1">&#39;Type:&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">isin</span><span class="p">(</span><span class="n">ch_anem</span><span class="p">)]</span><span class="o">.</span><span class="n">sort_values</span><span class="p">([</span><span class="s1">&#39;Height:&#39;</span><span class="p">],</span><span class="n">ascending</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="o">.</span><span class="n">iloc</span><span class="p">[[</span><span class="mi">0</span><span class="p">]]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">anem3</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">ch_info</span><span class="o">.</span><span class="n">loc</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">ch_info</span><span class="p">[</span><span class="s1">&#39;Type:&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">isin</span><span class="p">(</span><span class="n">ch_anem</span><span class="p">)]</span><span class="o">.</span><span class="n">sort_values</span><span class="p">([</span><span class="s1">&#39;Height:&#39;</span><span class="p">],</span><span class="n">ascending</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span><span class="o">.</span><span class="n">iloc</span><span class="p">[[</span><span class="mi">1</span><span class="p">]]</span>

            <span class="bp">self</span><span class="o">.</span><span class="n">vane1</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">ch_info</span><span class="o">.</span><span class="n">loc</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">ch_info</span><span class="p">[</span><span class="s1">&#39;Type:&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">isin</span><span class="p">(</span><span class="n">ch_vane</span><span class="p">)]</span><span class="o">.</span><span class="n">sort_values</span><span class="p">([</span><span class="s1">&#39;Height:&#39;</span><span class="p">],</span><span class="n">ascending</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span><span class="o">.</span><span class="n">iloc</span><span class="p">[[</span><span class="mi">0</span><span class="p">]]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">vane2</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">ch_info</span><span class="o">.</span><span class="n">loc</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">ch_info</span><span class="p">[</span><span class="s1">&#39;Type:&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">isin</span><span class="p">(</span><span class="n">ch_vane</span><span class="p">)]</span><span class="o">.</span><span class="n">sort_values</span><span class="p">([</span><span class="s1">&#39;Height:&#39;</span><span class="p">],</span><span class="n">ascending</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span><span class="o">.</span><span class="n">iloc</span><span class="p">[[</span><span class="mi">1</span><span class="p">]]</span>

            <span class="k">try</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">baro</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">ch_info</span><span class="o">.</span><span class="n">loc</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">ch_info</span><span class="p">[</span><span class="s1">&#39;Units:&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">isin</span><span class="p">(</span><span class="n">ch_baro</span><span class="p">)]</span><span class="o">.</span><span class="n">sort_values</span><span class="p">([</span><span class="s1">&#39;Height:&#39;</span><span class="p">],</span><span class="n">ascending</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span><span class="o">.</span><span class="n">iloc</span><span class="p">[[</span><span class="mi">0</span><span class="p">]]</span>
            <span class="k">except</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">baro</span> <span class="o">=</span> <span class="kc">None</span>
            <span class="k">try</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">relh</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">ch_info</span><span class="o">.</span><span class="n">loc</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">ch_info</span><span class="p">[</span><span class="s1">&#39;Units:&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">isin</span><span class="p">(</span><span class="n">ch_relh</span><span class="p">)]</span><span class="o">.</span><span class="n">sort_values</span><span class="p">([</span><span class="s1">&#39;Height:&#39;</span><span class="p">],</span><span class="n">ascending</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span><span class="o">.</span><span class="n">iloc</span><span class="p">[[</span><span class="mi">0</span><span class="p">]]</span>
            <span class="k">except</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">relh</span> <span class="o">=</span> <span class="kc">None</span>
            <span class="k">try</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">temp</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">ch_info</span><span class="o">.</span><span class="n">loc</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">ch_info</span><span class="p">[</span><span class="s1">&#39;Units:&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">isin</span><span class="p">(</span><span class="n">ch_temp</span><span class="p">)]</span><span class="o">.</span><span class="n">sort_values</span><span class="p">([</span><span class="s1">&#39;Height:&#39;</span><span class="p">],</span><span class="n">ascending</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span><span class="o">.</span><span class="n">iloc</span><span class="p">[[</span><span class="mi">0</span><span class="p">]]</span>
            <span class="k">except</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">temp</span> <span class="o">=</span> <span class="kc">None</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">make_header_for_epe</span><span class="p">()</span>

        <span class="c1"># select channels needed for soiling calculation</span>
        <span class="k">if</span> <span class="n">soiling</span> <span class="o">==</span> <span class="kc">True</span><span class="p">:</span>
            <span class="k">try</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">isc_clean</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">ch_info</span><span class="o">.</span><span class="n">loc</span><span class="p">[(</span><span class="bp">self</span><span class="o">.</span><span class="n">ch_info</span><span class="p">[</span><span class="s1">&#39;Description:&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">str</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span><span class="o">.</span><span class="n">str</span><span class="o">.</span><span class="n">contains</span><span class="p">(</span><span class="s1">&#39;|&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">ch_clean_desc</span><span class="p">))</span> <span class="o">&amp;</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">ch_info</span><span class="p">[</span><span class="s1">&#39;Units:&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">str</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span><span class="o">.</span><span class="n">str</span><span class="o">.</span><span class="n">contains</span><span class="p">(</span><span class="s1">&#39;|&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">ch_I_units</span><span class="p">))))]</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">isc_soiled</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">ch_info</span><span class="o">.</span><span class="n">loc</span><span class="p">[(</span><span class="bp">self</span><span class="o">.</span><span class="n">ch_info</span><span class="p">[</span><span class="s1">&#39;Description:&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">str</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span><span class="o">.</span><span class="n">str</span><span class="o">.</span><span class="n">contains</span><span class="p">(</span><span class="s1">&#39;|&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">ch_soiled_desc</span><span class="p">))</span> <span class="o">&amp;</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">ch_info</span><span class="p">[</span><span class="s1">&#39;Units:&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">str</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span><span class="o">.</span><span class="n">str</span><span class="o">.</span><span class="n">contains</span><span class="p">(</span><span class="s1">&#39;|&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">ch_I_units</span><span class="p">))))]</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">pv_temp_clean</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">ch_info</span><span class="o">.</span><span class="n">loc</span><span class="p">[(</span><span class="bp">self</span><span class="o">.</span><span class="n">ch_info</span><span class="p">[</span><span class="s1">&#39;Description:&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">str</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span><span class="o">.</span><span class="n">str</span><span class="o">.</span><span class="n">contains</span><span class="p">(</span><span class="s1">&#39;|&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">ch_clean_desc</span><span class="p">))</span> <span class="o">&amp;</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">ch_info</span><span class="p">[</span><span class="s1">&#39;Units:&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">str</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span><span class="o">.</span><span class="n">str</span><span class="o">.</span><span class="n">contains</span><span class="p">(</span><span class="s1">&#39;|&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">ch_temp</span><span class="p">))))]</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">pv_temp_soiled</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">ch_info</span><span class="o">.</span><span class="n">loc</span><span class="p">[(</span><span class="bp">self</span><span class="o">.</span><span class="n">ch_info</span><span class="p">[</span><span class="s1">&#39;Description:&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">str</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span><span class="o">.</span><span class="n">str</span><span class="o">.</span><span class="n">contains</span><span class="p">(</span><span class="s1">&#39;|&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">ch_soiled_desc</span><span class="p">))</span> <span class="o">&amp;</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">ch_info</span><span class="p">[</span><span class="s1">&#39;Units:&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">str</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span><span class="o">.</span><span class="n">str</span><span class="o">.</span><span class="n">contains</span><span class="p">(</span><span class="s1">&#39;|&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">ch_temp</span><span class="p">))))]</span>
            <span class="k">except</span><span class="p">:</span>
                <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;SC and PV Temp fields unavailable for calculation&quot;</span><span class="p">)</span></div>


<div class="viewcode-block" id="sympro_txt_read.format_data_for_epe"><a class="viewcode-back" href="../../../nrgpy.read.html#nrgpy.read.sympro_txt.sympro_txt_read.format_data_for_epe">[docs]</a>    <span class="k">def</span> <span class="nf">format_data_for_epe</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">baro_ch</span> <span class="o">=</span> <span class="s2">&quot;Ch&quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">baro</span><span class="p">[</span><span class="s1">&#39;Channel:&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">iloc</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="o">+</span> <span class="s2">&quot;_&quot;</span>
        <span class="n">temp_ch</span> <span class="o">=</span> <span class="s2">&quot;Ch&quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">temp</span><span class="p">[</span><span class="s1">&#39;Channel:&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">iloc</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="o">+</span> <span class="s2">&quot;_&quot;</span>
        <span class="n">relh_ch</span> <span class="o">=</span> <span class="s2">&quot;Ch&quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">relh</span><span class="p">[</span><span class="s1">&#39;Channel:&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">iloc</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="o">+</span> <span class="s2">&quot;_&quot;</span>
        <span class="n">anem1_ch</span> <span class="o">=</span> <span class="s2">&quot;Ch&quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">anem1</span><span class="p">[</span><span class="s1">&#39;Channel:&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">iloc</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="o">+</span> <span class="s2">&quot;_&quot;</span>
        <span class="n">anem2_ch</span> <span class="o">=</span> <span class="s2">&quot;Ch&quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">anem2</span><span class="p">[</span><span class="s1">&#39;Channel:&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">iloc</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="o">+</span> <span class="s2">&quot;_&quot;</span>
        <span class="n">anem3_ch</span> <span class="o">=</span> <span class="s2">&quot;Ch&quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">anem3</span><span class="p">[</span><span class="s1">&#39;Channel:&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">iloc</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="o">+</span> <span class="s2">&quot;_&quot;</span>
        <span class="n">vane1_ch</span> <span class="o">=</span> <span class="s2">&quot;Ch&quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">vane1</span><span class="p">[</span><span class="s1">&#39;Channel:&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">iloc</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="o">+</span> <span class="s2">&quot;_&quot;</span>
        <span class="n">vane2_ch</span> <span class="o">=</span> <span class="s2">&quot;Ch&quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">vane2</span><span class="p">[</span><span class="s1">&#39;Channel:&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">iloc</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="o">+</span> <span class="s2">&quot;_&quot;</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;CH01&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;Timestamp&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">str</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39; &#39;</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">str</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">str</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">&#39;-&#39;</span><span class="p">,</span><span class="s1">&#39;&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;CH02&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;Timestamp&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">str</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39; &#39;</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">str</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">str</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">&#39;:&#39;</span><span class="p">,</span><span class="s1">&#39;&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;CH03&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;000&quot;</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;CH04&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[[</span><span class="n">col</span> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">columns</span> <span class="k">if</span> <span class="p">(</span><span class="n">baro_ch</span> <span class="ow">in</span> <span class="n">col</span> <span class="ow">and</span> <span class="s1">&#39;Avg&#39;</span> <span class="ow">in</span> <span class="n">col</span><span class="p">)]]</span>
        <span class="k">except</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;CH04&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;000&quot;</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;CH05&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[[</span><span class="n">col</span> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">columns</span> <span class="k">if</span> <span class="p">(</span><span class="n">temp_ch</span> <span class="ow">in</span> <span class="n">col</span> <span class="ow">and</span> <span class="s1">&#39;Avg&#39;</span> <span class="ow">in</span> <span class="n">col</span><span class="p">)]]</span>
        <span class="k">except</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;CH05&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;000&quot;</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;CH06&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[[</span><span class="n">col</span> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">columns</span> <span class="k">if</span> <span class="p">(</span><span class="n">relh_ch</span> <span class="ow">in</span> <span class="n">col</span> <span class="ow">and</span> <span class="s1">&#39;Avg&#39;</span> <span class="ow">in</span> <span class="n">col</span><span class="p">)]]</span>
        <span class="k">except</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;CH06&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;000&quot;</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;CH07&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[[</span><span class="n">col</span> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">columns</span> <span class="k">if</span> <span class="p">(</span><span class="n">anem1_ch</span> <span class="ow">in</span> <span class="n">col</span> <span class="ow">and</span> <span class="s1">&#39;Avg&#39;</span> <span class="ow">in</span> <span class="n">col</span><span class="p">)]]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;CH08&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[[</span><span class="n">col</span> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">columns</span> <span class="k">if</span> <span class="p">(</span><span class="n">anem1_ch</span> <span class="ow">in</span> <span class="n">col</span> <span class="ow">and</span> <span class="s1">&#39;Max&#39;</span> <span class="ow">in</span> <span class="n">col</span><span class="p">)]]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;CH09&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[[</span><span class="n">col</span> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">columns</span> <span class="k">if</span> <span class="p">(</span><span class="n">anem1_ch</span> <span class="ow">in</span> <span class="n">col</span> <span class="ow">and</span> <span class="s1">&#39;Min&#39;</span> <span class="ow">in</span> <span class="n">col</span><span class="p">)]]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;CH10&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[[</span><span class="n">col</span> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">columns</span> <span class="k">if</span> <span class="p">(</span><span class="n">anem1_ch</span> <span class="ow">in</span> <span class="n">col</span> <span class="ow">and</span> <span class="s1">&#39;SD&#39;</span> <span class="ow">in</span> <span class="n">col</span><span class="p">)]]</span>
        <span class="k">except</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;CH07&#39;</span><span class="p">],</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;CH08&#39;</span><span class="p">],</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;CH09&#39;</span><span class="p">],</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;CH10&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;000&quot;</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;CH11&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[[</span><span class="n">col</span> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">columns</span> <span class="k">if</span> <span class="p">(</span><span class="n">vane1_ch</span> <span class="ow">in</span> <span class="n">col</span> <span class="ow">and</span> <span class="s1">&#39;Avg&#39;</span> <span class="ow">in</span> <span class="n">col</span><span class="p">)]]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;CH12&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[[</span><span class="n">col</span> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">columns</span> <span class="k">if</span> <span class="p">(</span><span class="n">vane1_ch</span> <span class="ow">in</span> <span class="n">col</span> <span class="ow">and</span> <span class="s1">&#39;SD&#39;</span> <span class="ow">in</span> <span class="n">col</span><span class="p">)]]</span>
        <span class="k">except</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;CH11&#39;</span><span class="p">],</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;CH12&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;000&quot;</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;CH13&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[[</span><span class="n">col</span> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">columns</span> <span class="k">if</span> <span class="p">(</span><span class="n">anem2_ch</span> <span class="ow">in</span> <span class="n">col</span> <span class="ow">and</span> <span class="s1">&#39;Avg&#39;</span> <span class="ow">in</span> <span class="n">col</span><span class="p">)]]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;CH14&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[[</span><span class="n">col</span> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">columns</span> <span class="k">if</span> <span class="p">(</span><span class="n">anem2_ch</span> <span class="ow">in</span> <span class="n">col</span> <span class="ow">and</span> <span class="s1">&#39;Max&#39;</span> <span class="ow">in</span> <span class="n">col</span><span class="p">)]]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;CH15&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[[</span><span class="n">col</span> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">columns</span> <span class="k">if</span> <span class="p">(</span><span class="n">anem2_ch</span> <span class="ow">in</span> <span class="n">col</span> <span class="ow">and</span> <span class="s1">&#39;Min&#39;</span> <span class="ow">in</span> <span class="n">col</span><span class="p">)]]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;CH16&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[[</span><span class="n">col</span> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">columns</span> <span class="k">if</span> <span class="p">(</span><span class="n">anem2_ch</span> <span class="ow">in</span> <span class="n">col</span> <span class="ow">and</span> <span class="s1">&#39;SD&#39;</span> <span class="ow">in</span> <span class="n">col</span><span class="p">)]]</span>
        <span class="k">except</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;CH13&#39;</span><span class="p">],</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;CH14&#39;</span><span class="p">],</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;CH15&#39;</span><span class="p">],</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;CH16&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;000&quot;</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;CH17&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[[</span><span class="n">col</span> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">columns</span> <span class="k">if</span> <span class="p">(</span><span class="n">vane2_ch</span> <span class="ow">in</span> <span class="n">col</span> <span class="ow">and</span> <span class="s1">&#39;Avg&#39;</span> <span class="ow">in</span> <span class="n">col</span><span class="p">)]]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;CH18&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[[</span><span class="n">col</span> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">columns</span> <span class="k">if</span> <span class="p">(</span><span class="n">vane2_ch</span> <span class="ow">in</span> <span class="n">col</span> <span class="ow">and</span> <span class="s1">&#39;SD&#39;</span> <span class="ow">in</span> <span class="n">col</span><span class="p">)]]</span>
        <span class="k">except</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;CH17&#39;</span><span class="p">],</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;CH18&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;000&quot;</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;CH19&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[[</span><span class="n">col</span> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">columns</span> <span class="k">if</span> <span class="p">(</span><span class="n">anem3_ch</span> <span class="ow">in</span> <span class="n">col</span> <span class="ow">and</span> <span class="s1">&#39;Avg&#39;</span> <span class="ow">in</span> <span class="n">col</span><span class="p">)]]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;CH20&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[[</span><span class="n">col</span> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">columns</span> <span class="k">if</span> <span class="p">(</span><span class="n">anem3_ch</span> <span class="ow">in</span> <span class="n">col</span> <span class="ow">and</span> <span class="s1">&#39;Max&#39;</span> <span class="ow">in</span> <span class="n">col</span><span class="p">)]]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;CH21&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[[</span><span class="n">col</span> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">columns</span> <span class="k">if</span> <span class="p">(</span><span class="n">anem3_ch</span> <span class="ow">in</span> <span class="n">col</span> <span class="ow">and</span> <span class="s1">&#39;Min&#39;</span> <span class="ow">in</span> <span class="n">col</span><span class="p">)]]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;CH22&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[[</span><span class="n">col</span> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">columns</span> <span class="k">if</span> <span class="p">(</span><span class="n">anem3_ch</span> <span class="ow">in</span> <span class="n">col</span> <span class="ow">and</span> <span class="s1">&#39;SD&#39;</span> <span class="ow">in</span> <span class="n">col</span><span class="p">)]]</span>
        <span class="k">except</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;CH19&#39;</span><span class="p">],</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;CH20&#39;</span><span class="p">],</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;CH21&#39;</span><span class="p">],</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;CH22&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;000&quot;</span></div>


<div class="viewcode-block" id="sympro_txt_read.make_header_for_epe"><a class="viewcode-back" href="../../../nrgpy.read.html#nrgpy.read.sympro_txt.sympro_txt_read.make_header_for_epe">[docs]</a>    <span class="k">def</span> <span class="nf">make_header_for_epe</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">array</span>     <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;Site Number:&#39;</span><span class="p">]</span>
        <span class="n">sitenum</span>   <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">site_info</span><span class="o">.</span><span class="n">loc</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">site_info</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">isin</span><span class="p">(</span><span class="n">array</span><span class="p">)][</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">to_string</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot; &quot;</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
        <span class="n">starttime</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">head</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">values</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">&quot;-&quot;</span><span class="p">,</span><span class="s2">&quot;&quot;</span><span class="p">)</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">&quot; &quot;</span><span class="p">,</span><span class="s2">&quot;&quot;</span><span class="p">)</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">&quot;:&quot;</span><span class="p">,</span><span class="s2">&quot;&quot;</span><span class="p">)</span>
        <span class="n">endtime</span>   <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">tail</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">values</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">&quot;-&quot;</span><span class="p">,</span><span class="s2">&quot;&quot;</span><span class="p">)</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">&quot; &quot;</span><span class="p">,</span><span class="s2">&quot;&quot;</span><span class="p">)</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">&quot;:&quot;</span><span class="p">,</span><span class="s2">&quot;&quot;</span><span class="p">)</span>

        <span class="n">a1_height</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">anem1</span><span class="p">[</span><span class="s1">&#39;Height:&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">iloc</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
        <span class="n">a2_height</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">anem2</span><span class="p">[</span><span class="s1">&#39;Height:&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">iloc</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
        <span class="n">a3_height</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">anem3</span><span class="p">[</span><span class="s1">&#39;Height:&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">iloc</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
        <span class="n">v1_height</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">vane1</span><span class="p">[</span><span class="s1">&#39;Height:&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">iloc</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
        <span class="n">v2_height</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">vane2</span><span class="p">[</span><span class="s1">&#39;Height:&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">iloc</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>

        <span class="n">header</span> <span class="o">=</span> <span class="p">[]</span>

        <span class="n">header</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;Estaçao &#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">sitenum</span><span class="p">))</span>
        <span class="n">header</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;Início &#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">starttime</span><span class="p">))</span>
        <span class="n">header</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;Fim &#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">endtime</span><span class="p">))</span>
        <span class="n">header</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;CH01 Dia do início do intervalo (de 10 minutos) de medição [AAAMMDD]&#39;</span><span class="p">)</span>
        <span class="n">header</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;CH02 Horário do início do intervalo (de 10 minutos) de medição [hhmmss]&#39;</span><span class="p">)</span>
        <span class="n">header</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;CH03 Código de erro do intervalo, com &quot;0&quot; indicando medição sem erro&#39;</span><span class="p">)</span>
        <span class="n">header</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;CH04 Pressão do ar [hPa]: média do intervalo&#39;</span><span class="p">)</span>
        <span class="n">header</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;CH05 Temperatura do ar [°C]: média do intervalo&#39;</span><span class="p">)</span>
        <span class="n">header</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;CH06 Umidade relativa do ar [</span><span class="si">%r</span><span class="s1">el]: média do intervalo&#39;</span><span class="p">)</span>
        <span class="n">header</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;CH07 Anemômetro superior &#39;</span><span class="o">+</span><span class="n">a1_height</span><span class="o">+</span><span class="s1">&#39;, velocidade do vento [m/s]: média do intervalo&#39;</span><span class="p">)</span>
        <span class="n">header</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;CH08 Anemômetro superior &#39;</span><span class="o">+</span><span class="n">a1_height</span><span class="o">+</span><span class="s1">&#39;, velocidade do vento [m/s]: máximo do intervalo&#39;</span><span class="p">)</span>
        <span class="n">header</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;CH09 Anemômetro superior &#39;</span><span class="o">+</span><span class="n">a1_height</span><span class="o">+</span><span class="s1">&#39;, velocidade do vento [m/s]: mínimo do intervalo&#39;</span><span class="p">)</span>
        <span class="n">header</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;CH10 Anemômetro superior &#39;</span><span class="o">+</span><span class="n">a1_height</span><span class="o">+</span><span class="s1">&#39;, velocidade do vento [m/s]: desvio padrão do intervalo&#39;</span><span class="p">)</span>
        <span class="n">header</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;CH11 Wind Vane superior &#39;</span><span class="o">+</span><span class="n">v1_height</span><span class="o">+</span><span class="s1">&#39;, direção de vento [°]: média do intervalo&#39;</span><span class="p">)</span>
        <span class="n">header</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;CH12 Wind Vane superior &#39;</span><span class="o">+</span><span class="n">v1_height</span><span class="o">+</span><span class="s1">&#39;, direção de vento [°]: desvio padrão do intervalo&#39;</span><span class="p">)</span>
        <span class="n">header</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;CH13 Anemômetro 2 &#39;</span><span class="o">+</span><span class="n">a2_height</span><span class="o">+</span><span class="s1">&#39;, velocidade do vento [m/s]: média do intervalo&#39;</span><span class="p">)</span>
        <span class="n">header</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;CH14 Anemômetro 2 &#39;</span><span class="o">+</span><span class="n">a2_height</span><span class="o">+</span><span class="s1">&#39;, velocidade do vento [m/s]: máximo do intervalo&#39;</span><span class="p">)</span>
        <span class="n">header</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;CH15 Anemômetro 2 &#39;</span><span class="o">+</span><span class="n">a2_height</span><span class="o">+</span><span class="s1">&#39;, velocidade do vento [m/s]: mínimo do intervalo&#39;</span><span class="p">)</span>
        <span class="n">header</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;CH16 Anemômetro 2 &#39;</span><span class="o">+</span><span class="n">a2_height</span><span class="o">+</span><span class="s1">&#39;, velocidade do vento [m/s]: desvio padrão do intervalo&#39;</span><span class="p">)</span>
        <span class="n">header</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;CH17 Wind Vane 2 &#39;</span><span class="o">+</span><span class="n">v2_height</span><span class="o">+</span><span class="s1">&#39;, direção de vento [°]: média do intervalo&#39;</span><span class="p">)</span>
        <span class="n">header</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;CH18 Wind Vane 2 &#39;</span><span class="o">+</span><span class="n">v2_height</span><span class="o">+</span><span class="s1">&#39;, direção de vento [°]: média do intervalo&#39;</span><span class="p">)</span>
        <span class="n">header</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;CH19 Anemômetro 3 &#39;</span><span class="o">+</span><span class="n">a3_height</span><span class="o">+</span><span class="s1">&#39;, velocidade do vento [m/s]: média do intervalo&#39;</span><span class="p">)</span>
        <span class="n">header</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;CH20 Anemômetro 3 &#39;</span><span class="o">+</span><span class="n">a3_height</span><span class="o">+</span><span class="s1">&#39;, velocidade do vento [m/s]: máximo do intervalo&#39;</span><span class="p">)</span>
        <span class="n">header</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;CH21 Anemômetro 3 &#39;</span><span class="o">+</span><span class="n">a3_height</span><span class="o">+</span><span class="s1">&#39;, velocidade do vento [m/s]: mínimo do intervalo&#39;</span><span class="p">)</span>
        <span class="n">header</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;CH22 Anemômetro 3 &#39;</span><span class="o">+</span><span class="n">a3_height</span><span class="o">+</span><span class="s1">&#39;, velocidade do vento [m/s]: desvio padrão do intervalo&#39;</span><span class="p">)</span>
        <span class="n">header</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;CH01|CH02|CH03|CH04|CH05|CH06|CH07|CH08|CH09|CH10|CH11|CH12|CH13|CH14|CH15|CH16|CH17|CH18|CH19|CH20|CH21|CH22|&#39;</span><span class="p">)</span>
        <span class="n">header</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;dados&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">header</span> <span class="o">=</span> <span class="n">header</span></div>


<div class="viewcode-block" id="sympro_txt_read.calculate_soiling_ratio"><a class="viewcode-back" href="../../../nrgpy.read.html#nrgpy.read.sympro_txt.sympro_txt_read.calculate_soiling_ratio">[docs]</a>    <span class="k">def</span> <span class="nf">calculate_soiling_ratio</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">method</span><span class="o">=</span><span class="s2">&quot;IEC&quot;</span><span class="p">,</span> <span class="n">T0</span><span class="o">=</span><span class="mi">25</span><span class="p">,</span> <span class="n">G0</span><span class="o">=</span><span class="mi">1000</span><span class="p">,</span> <span class="n">alpha</span><span class="o">=</span><span class="mf">0.0004</span><span class="p">,</span>
                                <span class="n">I_clean_SC_0</span><span class="o">=</span><span class="mf">0.900000</span><span class="p">,</span> <span class="n">I_soiled_SC_0</span><span class="o">=</span><span class="mf">0.900000</span> <span class="p">):</span>
        <span class="n">isc_clean_ch</span> <span class="o">=</span> <span class="s2">&quot;Ch&quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">isc_clean</span><span class="p">[</span><span class="s1">&#39;Channel:&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">iloc</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="o">+</span> <span class="s2">&quot;_&quot;</span>
        <span class="n">isc_soiled_ch</span> <span class="o">=</span> <span class="s2">&quot;Ch&quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">isc_soiled</span><span class="p">[</span><span class="s1">&#39;Channel:&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">iloc</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="o">+</span> <span class="s2">&quot;_&quot;</span>
        <span class="n">pv_clean_ch</span> <span class="o">=</span> <span class="s2">&quot;Ch&quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">pv_temp_clean</span><span class="p">[</span><span class="s1">&#39;Channel:&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">iloc</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="o">+</span> <span class="s2">&quot;_&quot;</span>
        <span class="n">pv_soiled_ch</span> <span class="o">=</span> <span class="s2">&quot;Ch&quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">pv_temp_soiled</span><span class="p">[</span><span class="s1">&#39;Channel:&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">iloc</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="o">+</span> <span class="s2">&quot;_&quot;</span>

        <span class="k">try</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;I_clean_SC&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[[</span><span class="n">col</span> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">columns</span> <span class="k">if</span> <span class="p">(</span><span class="n">isc_clean_ch</span> <span class="ow">in</span> <span class="n">col</span> <span class="ow">and</span> <span class="s1">&#39;Avg&#39;</span> <span class="ow">in</span> <span class="n">col</span><span class="p">)]]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;I_soiled_SC&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[[</span><span class="n">col</span> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">columns</span> <span class="k">if</span> <span class="p">(</span><span class="n">isc_soiled_ch</span> <span class="ow">in</span> <span class="n">col</span> <span class="ow">and</span> <span class="s1">&#39;Avg&#39;</span> <span class="ow">in</span> <span class="n">col</span><span class="p">)]]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;T_clean&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[[</span><span class="n">col</span> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">columns</span> <span class="k">if</span> <span class="p">(</span><span class="n">pv_clean_ch</span> <span class="ow">in</span> <span class="n">col</span> <span class="ow">and</span> <span class="s1">&#39;Avg&#39;</span> <span class="ow">in</span> <span class="n">col</span><span class="p">)]]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;T_soiled&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[[</span><span class="n">col</span> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">columns</span> <span class="k">if</span> <span class="p">(</span><span class="n">pv_soiled_ch</span> <span class="ow">in</span> <span class="n">col</span> <span class="ow">and</span> <span class="s1">&#39;Avg&#39;</span> <span class="ow">in</span> <span class="n">col</span><span class="p">)]]</span>

        <span class="k">except</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;error replicating ISC or PV data&quot;</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">method</span> <span class="o">==</span> <span class="s2">&quot;IEC&quot;</span><span class="p">:</span>
            <span class="k">try</span><span class="p">:</span>
                <span class="c1"># calculate G</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;G&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">G0</span> <span class="o">*</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;I_clean_SC&#39;</span><span class="p">]</span> <span class="o">*</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">alpha</span> <span class="o">*</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;T_clean&#39;</span><span class="p">]</span> <span class="o">-</span> <span class="n">T0</span><span class="p">)))</span> <span class="o">/</span> <span class="n">I_clean_SC_0</span>
            <span class="k">except</span><span class="p">:</span>
                <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;could not calculate G column&quot;</span><span class="p">)</span>
            <span class="k">try</span><span class="p">:</span>
                <span class="c1"># calculate SR</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;SR&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;I_soiled_SC&#39;</span><span class="p">]</span> <span class="o">/</span> <span class="p">(</span><span class="n">I_soiled_SC_0</span> <span class="o">*</span> <span class="p">(</span><span class="mi">1</span> <span class="o">+</span> <span class="p">(</span><span class="n">alpha</span> <span class="o">*</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;T_soiled&#39;</span><span class="p">]</span> <span class="o">-</span> <span class="n">T0</span><span class="p">)))</span> <span class="o">*</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;G&#39;</span><span class="p">]</span> <span class="o">/</span> <span class="n">G0</span><span class="p">))</span>
            <span class="k">except</span><span class="p">:</span>
                <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;could not calculate SR column&quot;</span><span class="p">)</span></div>


<div class="viewcode-block" id="sympro_txt_read.output_txt_file"><a class="viewcode-back" href="../../../nrgpy.read.html#nrgpy.read.sympro_txt.sympro_txt_read.output_txt_file">[docs]</a>    <span class="k">def</span> <span class="nf">output_txt_file</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">epe</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">soiling</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">standard</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
                        <span class="n">shift_timestamps</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">out_file</span><span class="o">=</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>

        <span class="n">out_dir</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;out_dir&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">epe</span> <span class="o">==</span> <span class="kc">True</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">out_file</span> <span class="o">!=</span> <span class="s1">&#39;&#39;</span><span class="p">:</span>
                <span class="n">output_name</span> <span class="o">=</span> <span class="n">out_file</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">output_name</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">out_file</span><span class="p">[:</span><span class="o">-</span><span class="mi">4</span><span class="p">]</span><span class="o">+</span><span class="s2">&quot;_EPE.txt&quot;</span>
            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">Outputting file: </span><span class="si">{0}</span><span class="s2">   ...   &quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">output_name</span><span class="p">),</span> <span class="n">end</span><span class="o">=</span><span class="s2">&quot;&quot;</span><span class="p">,</span> <span class="n">flush</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>

            <span class="k">try</span><span class="p">:</span>
                <span class="n">output_file</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="n">output_name</span><span class="p">,</span> <span class="s1">&#39;w+&#39;</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="s1">&#39;utf-16&#39;</span><span class="p">)</span>
                <span class="n">output_file</span><span class="o">.</span><span class="n">truncate</span><span class="p">()</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">select_channels_for_reformat</span><span class="p">(</span><span class="n">epe</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">format_data_for_epe</span><span class="p">()</span>

                <span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">header</span><span class="p">:</span>
                    <span class="k">try</span><span class="p">:</span>
                        <span class="n">output_file</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">line</span> <span class="o">+</span> <span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">)</span>
                    <span class="k">except</span><span class="p">:</span>
                        <span class="k">pass</span>
                <span class="n">output_file</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>

                <span class="n">col_prefix</span> <span class="o">=</span> <span class="s2">&quot;CH&quot;</span>
                <span class="n">cols</span> <span class="o">=</span> <span class="p">[]</span>
                <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">23</span><span class="p">,</span><span class="mi">1</span><span class="p">):</span>
                    <span class="n">col_num</span>  <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">i</span><span class="p">)</span><span class="o">.</span><span class="n">zfill</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
                    <span class="n">col_name</span> <span class="o">=</span> <span class="n">col_prefix</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">col_num</span><span class="p">)</span>
                    <span class="n">cols</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">col_name</span><span class="p">)</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">cols</span> <span class="o">=</span> <span class="n">cols</span>

                <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">output_name</span><span class="p">,</span> <span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="s1">&#39;utf-16&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">to_csv</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">header</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">&quot;|&quot;</span><span class="p">,</span> <span class="n">columns</span><span class="o">=</span><span class="n">cols</span><span class="p">,</span> <span class="n">index</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
                                    <span class="n">index_label</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">decimal</span><span class="o">=</span><span class="s2">&quot;,&quot;</span><span class="p">,</span> <span class="n">line_terminator</span><span class="o">=</span><span class="s2">&quot;|</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">,</span>
                                    <span class="n">float_format</span><span class="o">=</span><span class="s1">&#39;</span><span class="si">%.2f</span><span class="s1">&#39;</span><span class="p">)</span>

                <span class="n">f</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
                <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;[OK]&quot;</span><span class="p">)</span>

            <span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
                <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;[FAILED]&quot;</span><span class="p">)</span>
                <span class="nb">print</span><span class="p">(</span><span class="n">e</span><span class="p">)</span>

        <span class="k">else</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">soiling</span> <span class="o">==</span> <span class="kc">True</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">out_file</span> <span class="o">!=</span> <span class="s1">&#39;&#39;</span><span class="p">:</span>
                    <span class="n">output_name</span> <span class="o">=</span> <span class="n">out_file</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="n">output_name</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">out_file</span><span class="p">[:</span><span class="o">-</span><span class="mi">4</span><span class="p">]</span><span class="o">+</span><span class="s2">&quot;_soiling.txt&quot;</span>

                <span class="n">output_file</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="n">output_name</span><span class="p">,</span> <span class="s1">&#39;w+&#39;</span><span class="p">,</span> <span class="n">encoding</span> <span class="o">=</span> <span class="s1">&#39;utf-8&#39;</span><span class="p">)</span>
                <span class="n">output_file</span><span class="o">.</span><span class="n">truncate</span><span class="p">()</span>
                <span class="n">output_file</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">head</span><span class="p">)</span>
                <span class="n">output_file</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>

                <span class="c1"># write header</span>
                <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">output_name</span><span class="p">,</span> <span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="s1">&#39;utf-8&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">site_info</span><span class="o">.</span><span class="n">to_csv</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">header</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">&quot;</span><span class="se">\t</span><span class="s2">&quot;</span><span class="p">,</span> <span class="n">index</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
                                        <span class="n">index_label</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">line_terminator</span><span class="o">=</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">)</span>

                <span class="n">output_file</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>

                <span class="c1">#write data</span>
                <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">output_name</span><span class="p">,</span> <span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="s1">&#39;utf-8&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">round</span><span class="p">(</span><span class="mi">6</span><span class="p">)</span><span class="o">.</span><span class="n">to_csv</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">header</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">&quot;</span><span class="se">\t</span><span class="s2">&quot;</span><span class="p">,</span> <span class="n">index</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
                                        <span class="n">index_label</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">line_terminator</span><span class="o">=</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">)</span>
                <span class="n">output_file</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>


            <span class="k">if</span> <span class="n">shift_timestamps</span> <span class="o">==</span> <span class="kc">True</span><span class="p">:</span>

                <span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span><span class="n">out_dir</span><span class="p">,</span> <span class="n">exist_ok</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
                <span class="n">file_date</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">iloc</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="s1">&#39;Timestamp&#39;</span><span class="p">])</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">&quot; &quot;</span><span class="p">,</span><span class="s2">&quot;_&quot;</span><span class="p">)</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">&quot;:&quot;</span><span class="p">,</span><span class="s2">&quot;.&quot;</span><span class="p">)[:</span><span class="o">-</span><span class="mi">3</span><span class="p">]</span>
                <span class="n">file_num</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">filename</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;_&quot;</span><span class="p">)[</span><span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">filename</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;_&quot;</span><span class="p">))</span> <span class="o">-</span> <span class="mi">2</span><span class="p">]</span>
                <span class="n">file_name</span> <span class="o">=</span> <span class="s2">&quot;</span><span class="si">{0}</span><span class="s2">_</span><span class="si">{1}</span><span class="s2">_</span><span class="si">{2}</span><span class="s2">_meas.txt&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">site_number</span><span class="p">,</span> <span class="n">file_date</span><span class="p">,</span> <span class="n">file_num</span><span class="p">)</span>
                <span class="n">output_name</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">out_dir</span><span class="p">,</span> <span class="n">file_name</span><span class="p">)</span>

                <span class="bp">self</span><span class="o">.</span><span class="n">output_name</span> <span class="o">=</span> <span class="n">output_name</span>
                <span class="n">output_file</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="n">output_name</span><span class="p">,</span> <span class="s1">&#39;w+&#39;</span><span class="p">,</span> <span class="n">encoding</span> <span class="o">=</span> <span class="s1">&#39;utf-8&#39;</span><span class="p">)</span>
                <span class="n">output_file</span><span class="o">.</span><span class="n">truncate</span><span class="p">()</span>
                <span class="n">output_file</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">head</span><span class="p">)</span>
                <span class="n">output_file</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>

                <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">output_name</span><span class="p">,</span> <span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="s1">&#39;utf-8&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
                    <span class="k">try</span><span class="p">:</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">site_info</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">site_info</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">first_timestamp</span><span class="p">,</span><span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">iloc</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="s1">&#39;Timestamp&#39;</span><span class="p">]))</span>
                    <span class="k">except</span><span class="p">:</span>
                        <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;couldn&#39;t rename &#39;Effective Date:&#39; info in </span><span class="si">{0}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">output_name</span><span class="p">))</span>
                        <span class="k">pass</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">site_info</span><span class="o">.</span><span class="n">to_csv</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">header</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">&quot;</span><span class="se">\t</span><span class="s2">&quot;</span><span class="p">,</span> <span class="n">index</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
                                        <span class="n">index_label</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">line_terminator</span><span class="o">=</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">)</span>

                <span class="n">output_file</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>

                <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">output_name</span><span class="p">,</span> <span class="s1">&#39;U&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
                    <span class="n">text</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">read</span><span class="p">()</span>
                    <span class="k">while</span> <span class="s1">&#39;</span><span class="se">\t\n</span><span class="s1">&#39;</span> <span class="ow">in</span> <span class="n">text</span><span class="p">:</span>
                        <span class="n">text</span> <span class="o">=</span> <span class="n">text</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\t\n</span><span class="s1">&#39;</span><span class="p">,</span><span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>

                <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">output_name</span><span class="p">,</span> <span class="s1">&#39;w&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
                    <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">text</span><span class="p">)</span>

                <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">output_name</span><span class="p">,</span> <span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="s1">&#39;utf-8&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">round</span><span class="p">(</span><span class="mi">6</span><span class="p">)</span><span class="o">.</span><span class="n">to_csv</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">header</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">&quot;</span><span class="se">\t</span><span class="s2">&quot;</span><span class="p">,</span> <span class="n">index</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
                                        <span class="n">index_label</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">line_terminator</span><span class="o">=</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">)</span>

                <span class="n">output_file</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">insert_blank_header_rows</span><span class="p">(</span><span class="n">output_name</span><span class="p">)</span>

            <span class="k">if</span> <span class="n">standard</span> <span class="o">==</span> <span class="kc">True</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">out_file</span> <span class="o">!=</span> <span class="s1">&#39;&#39;</span><span class="p">:</span>
                    <span class="n">output_name</span> <span class="o">=</span> <span class="n">out_file</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="n">output_name</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">out_file</span><span class="p">[:</span><span class="o">-</span><span class="mi">4</span><span class="p">]</span><span class="o">+</span><span class="s2">&quot;_standard.txt&quot;</span>

                <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">Outputting file: </span><span class="si">{0}</span><span class="s2">   ...   &quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">output_name</span><span class="p">),</span> <span class="n">end</span><span class="o">=</span><span class="s2">&quot;&quot;</span><span class="p">,</span> <span class="n">flush</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>

                <span class="k">try</span><span class="p">:</span>
                    <span class="n">output_file</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="n">output_name</span><span class="p">,</span> <span class="s1">&#39;w+&#39;</span><span class="p">,</span> <span class="n">encoding</span> <span class="o">=</span> <span class="s1">&#39;utf-8&#39;</span><span class="p">)</span>
                    <span class="n">output_file</span><span class="o">.</span><span class="n">truncate</span><span class="p">()</span>
                    <span class="n">output_file</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">head</span><span class="p">)</span>
                    <span class="n">output_file</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>

                    <span class="c1"># write header</span>
                    <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">output_name</span><span class="p">,</span> <span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="s1">&#39;utf-8&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">site_info</span><span class="o">.</span><span class="n">to_csv</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">header</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">&quot;</span><span class="se">\t</span><span class="s2">&quot;</span><span class="p">,</span> <span class="n">index</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
                                            <span class="n">index_label</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">line_terminator</span><span class="o">=</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">)</span>
                    <span class="n">output_file</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>

                    <span class="c1">#write data</span>
                    <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">output_name</span><span class="p">,</span> <span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="s1">&#39;utf-8&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">round</span><span class="p">(</span><span class="mi">6</span><span class="p">)</span><span class="o">.</span><span class="n">to_csv</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">header</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">&quot;</span><span class="se">\t</span><span class="s2">&quot;</span><span class="p">,</span> <span class="n">index</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
                                            <span class="n">index_label</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">line_terminator</span><span class="o">=</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">)</span>
                    <span class="n">output_file</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">insert_blank_header_rows</span><span class="p">(</span><span class="n">output_name</span><span class="p">)</span>
                    <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;[OK]&quot;</span><span class="p">)</span>

                <span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
                    <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;[FAILED]&quot;</span><span class="p">)</span>
                    <span class="nb">print</span><span class="p">(</span><span class="n">e</span><span class="p">)</span></div>


<div class="viewcode-block" id="sympro_txt_read.insert_blank_header_rows"><a class="viewcode-back" href="../../../nrgpy.read.html#nrgpy.read.sympro_txt.sympro_txt_read.insert_blank_header_rows">[docs]</a>    <span class="k">def</span> <span class="nf">insert_blank_header_rows</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">filename</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;insert blank rows when using shift_timestamps()</span>

<span class="sd">        ensures the resulting text file looks and feels like an</span>
<span class="sd">        original Sympro Desktop exported</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">header_section_headings</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;Export Parameters&quot;</span><span class="p">,</span>
                                   <span class="s2">&quot;Site Properties&quot;</span><span class="p">,</span>
                                   <span class="s2">&quot;Logger History&quot;</span><span class="p">,</span>
                                   <span class="s2">&quot;iPack History&quot;</span><span class="p">,</span>
                                   <span class="s2">&quot;Sensor History&quot;</span><span class="p">,</span>
                                   <span class="s2">&quot;Data&quot;</span><span class="p">]</span>

        <span class="n">blank_list</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">site_info</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">site_info</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">str</span><span class="o">.</span><span class="n">contains</span><span class="p">(</span><span class="s2">&quot;Export Parameters&quot;</span><span class="p">)</span> <span class="o">==</span> <span class="kc">True</span><span class="p">]</span><span class="o">.</span><span class="n">index</span><span class="p">:</span>
          <span class="n">blank_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">i</span><span class="p">)</span>
          <span class="n">export_parameter_line</span> <span class="o">=</span> <span class="n">i</span> <span class="o">+</span> <span class="mi">2</span>

        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">site_info</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">site_info</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">str</span><span class="o">.</span><span class="n">contains</span><span class="p">(</span><span class="s2">&quot;Site Properties&quot;</span><span class="p">)</span> <span class="o">==</span> <span class="kc">True</span><span class="p">]</span><span class="o">.</span><span class="n">index</span><span class="p">:</span>
           <span class="n">blank_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">i</span><span class="p">)</span>
           <span class="n">site_properties_line</span> <span class="o">=</span> <span class="n">i</span> <span class="o">+</span> <span class="mi">2</span>

        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">site_info</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">site_info</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">str</span><span class="o">.</span><span class="n">contains</span><span class="p">(</span><span class="s2">&quot;Logger History&quot;</span><span class="p">)</span> <span class="o">==</span> <span class="kc">True</span><span class="p">]</span><span class="o">.</span><span class="n">index</span><span class="p">:</span>
            <span class="n">blank_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">i</span><span class="p">)</span>
            <span class="n">logger_history_line</span> <span class="o">=</span> <span class="n">i</span> <span class="o">+</span> <span class="mi">2</span>

        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">site_info</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">site_info</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">str</span><span class="o">.</span><span class="n">contains</span><span class="p">(</span><span class="s2">&quot;iPack History&quot;</span><span class="p">)</span> <span class="o">==</span> <span class="kc">True</span><span class="p">]</span><span class="o">.</span><span class="n">index</span><span class="p">:</span>
            <span class="n">blank_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">i</span><span class="p">)</span>
            <span class="n">ipack_history_line</span> <span class="o">=</span> <span class="n">i</span> <span class="o">+</span> <span class="mi">2</span>

        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">site_info</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">site_info</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">str</span><span class="o">.</span><span class="n">contains</span><span class="p">(</span><span class="s2">&quot;Sensor History&quot;</span><span class="p">)</span> <span class="o">==</span> <span class="kc">True</span><span class="p">]</span><span class="o">.</span><span class="n">index</span><span class="p">:</span>
            <span class="n">blank_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">i</span><span class="p">)</span>
            <span class="n">sensor_history_line</span> <span class="o">=</span> <span class="n">i</span> <span class="o">+</span> <span class="mi">2</span>

        <span class="n">skip_first_channel</span> <span class="o">=</span> <span class="kc">True</span>
        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">site_info</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">site_info</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">str</span><span class="o">.</span><span class="n">contains</span><span class="p">(</span><span class="s2">&quot;Channel:&quot;</span><span class="p">)</span> <span class="o">==</span> <span class="kc">True</span><span class="p">]</span><span class="o">.</span><span class="n">index</span><span class="p">:</span>
           <span class="k">if</span> <span class="n">skip_first_channel</span> <span class="o">==</span> <span class="kc">True</span><span class="p">:</span>
                <span class="n">skip_first_channel</span> <span class="o">=</span> <span class="kc">False</span>
           <span class="k">else</span><span class="p">:</span>
              <span class="n">blank_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">i</span><span class="p">)</span>

        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">site_info</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">site_info</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">str</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="s2">&quot;Data&quot;</span><span class="p">)</span> <span class="o">==</span> <span class="kc">True</span><span class="p">]</span><span class="o">.</span><span class="n">index</span><span class="p">:</span>
           <span class="n">blank_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">i</span><span class="p">)</span>
           <span class="n">data_line</span> <span class="o">=</span> <span class="n">i</span> <span class="o">+</span> <span class="mi">2</span>

        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">site_info</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">site_info</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">str</span><span class="o">.</span><span class="n">contains</span><span class="p">(</span><span class="s2">&quot;Data Type:&quot;</span><span class="p">)</span> <span class="o">==</span> <span class="kc">True</span><span class="p">]</span><span class="o">.</span><span class="n">index</span><span class="p">:</span>
            <span class="n">blank_list</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">i</span><span class="p">)</span>

        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">site_info</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">site_info</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">str</span><span class="o">.</span><span class="n">contains</span><span class="p">(</span><span class="s2">&quot;Data Logging Mode:&quot;</span><span class="p">)</span> <span class="o">==</span> <span class="kc">True</span><span class="p">]</span><span class="o">.</span><span class="n">index</span><span class="p">:</span>
            <span class="n">blank_list</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">i</span><span class="p">)</span>

        <span class="n">f_read</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="s1">&#39;r&#39;</span><span class="p">)</span>
        <span class="n">contents</span> <span class="o">=</span> <span class="n">f_read</span><span class="o">.</span><span class="n">readlines</span><span class="p">()</span>
        <span class="n">f_read</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>

        <span class="n">contents</span><span class="p">[</span><span class="n">export_parameter_line</span><span class="p">]</span> <span class="o">=</span> <span class="n">header_section_headings</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span>
        <span class="n">contents</span><span class="p">[</span><span class="n">site_properties_line</span><span class="p">]</span>  <span class="o">=</span> <span class="n">header_section_headings</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span>
        <span class="n">contents</span><span class="p">[</span><span class="n">logger_history_line</span><span class="p">]</span>   <span class="o">=</span> <span class="n">header_section_headings</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">+</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span>
        <span class="n">contents</span><span class="p">[</span><span class="n">ipack_history_line</span><span class="p">]</span>    <span class="o">=</span> <span class="n">header_section_headings</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span> <span class="o">+</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span>
        <span class="n">contents</span><span class="p">[</span><span class="n">sensor_history_line</span><span class="p">]</span>   <span class="o">=</span> <span class="n">header_section_headings</span><span class="p">[</span><span class="mi">4</span><span class="p">]</span> <span class="o">+</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span>
        <span class="n">contents</span><span class="p">[</span><span class="n">data_line</span><span class="p">]</span>             <span class="o">=</span> <span class="n">header_section_headings</span><span class="p">[</span><span class="mi">5</span><span class="p">]</span> <span class="o">+</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span>

        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">list</span><span class="p">(</span><span class="nb">reversed</span><span class="p">(</span><span class="nb">sorted</span><span class="p">(</span><span class="n">blank_list</span><span class="p">))):</span>
            <span class="n">contents</span><span class="o">.</span><span class="n">insert</span><span class="p">(</span><span class="n">i</span><span class="o">+</span><span class="mi">2</span><span class="p">,</span> <span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">)</span>

        <span class="n">f_write</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="s1">&#39;w&#39;</span><span class="p">)</span>
        <span class="n">contents</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">contents</span><span class="p">)</span>
        <span class="n">f_write</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">contents</span><span class="p">)</span>
        <span class="n">f_write</span><span class="o">.</span><span class="n">close</span><span class="p">()</span></div></div>


<div class="viewcode-block" id="shift_timestamps"><a class="viewcode-back" href="../../../nrgpy.read.html#nrgpy.read.sympro_txt.shift_timestamps">[docs]</a><span class="k">def</span> <span class="nf">shift_timestamps</span><span class="p">(</span><span class="n">txt_folder</span><span class="o">=</span><span class="s2">&quot;&quot;</span><span class="p">,</span> <span class="n">out_folder</span><span class="o">=</span><span class="s2">&quot;&quot;</span><span class="p">,</span> <span class="n">file_filter</span><span class="o">=</span><span class="s2">&quot;&quot;</span><span class="p">,</span>
                     <span class="n">start_date</span><span class="o">=</span><span class="s2">&quot;1970-01-01&quot;</span><span class="p">,</span> <span class="n">end_date</span><span class="o">=</span><span class="s2">&quot;2150-12-31&quot;</span><span class="p">,</span>
                     <span class="n">seconds</span><span class="o">=</span><span class="mi">3600</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Takes as input a folder of exported standard text files and</span>
<span class="sd">    time to shift in seconds.</span>

<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    txt_folder : str</span>
<span class="sd">        path to folder with txt files to shift</span>
<span class="sd">    out_folder : str</span>
<span class="sd">        where to put the shifted files (in subfolder by default)</span>
<span class="sd">    file_filter : str</span>
<span class="sd">        filter for restricting file set</span>
<span class="sd">    start_date : str</span>
<span class="sd">        date filter &quot;YYYY-mm-dd&quot;</span>
<span class="sd">    end_date : str</span>
<span class="sd">        date filter &quot;YYYY-mm-dd&quot;</span>
<span class="sd">    seconds : int</span>
<span class="sd">        time in seconds to shift timestamps (default 3600)</span>

<span class="sd">    Returns</span>
<span class="sd">    -------</span>
<span class="sd">    obj</span>
<span class="sd">        text files with shifted timestamps; new file names include shifted</span>
<span class="sd">        timestamp.</span>

<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="n">out_folder</span><span class="p">:</span>
        <span class="n">out_dir</span> <span class="o">=</span> <span class="n">out_folder</span>
    <span class="k">else</span><span class="p">:</span>
        <span class="n">out_dir</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">txt_folder</span><span class="p">,</span> <span class="s2">&quot;shifted_timestamps&quot;</span><span class="p">)</span>

    <span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span><span class="n">out_dir</span><span class="p">,</span> <span class="n">exist_ok</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>

    <span class="n">files</span> <span class="o">=</span> <span class="p">[</span>
        <span class="n">f</span> <span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">glob</span><span class="p">(</span><span class="n">txt_folder</span> <span class="o">+</span> <span class="s2">&quot;/&quot;</span> <span class="o">+</span> <span class="s1">&#39;*.txt&#39;</span><span class="p">))</span>\
        <span class="k">if</span> <span class="n">file_filter</span> <span class="ow">in</span> <span class="n">f</span> <span class="ow">and</span> \
        <span class="n">date_check</span><span class="p">(</span><span class="n">start_date</span><span class="p">,</span> <span class="n">end_date</span><span class="p">,</span> <span class="n">f</span><span class="p">)</span>
    <span class="p">]</span>

    <span class="n">file_count</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">files</span><span class="p">)</span>
    <span class="n">counter</span> <span class="o">=</span> <span class="mi">1</span>
    <span class="n">start_time</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">now</span><span class="p">()</span>

    <span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">files</span><span class="p">:</span>

        <span class="k">try</span><span class="p">:</span>
            <span class="n">draw_progress_bar</span><span class="p">(</span><span class="n">counter</span><span class="p">,</span> <span class="n">file_count</span><span class="p">,</span> <span class="n">start_time</span><span class="p">)</span>
            <span class="n">f</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">txt_folder</span><span class="p">,</span> <span class="n">f</span><span class="p">)</span>
            <span class="n">fut</span> <span class="o">=</span> <span class="n">sympro_txt_read</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="n">f</span><span class="p">)</span>
            <span class="n">fut</span><span class="o">.</span><span class="n">format_site_data</span><span class="p">()</span>
            <span class="n">fut</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;Timestamp&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">to_datetime</span><span class="p">(</span><span class="n">fut</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;Timestamp&#39;</span><span class="p">])</span> <span class="o">+</span> <span class="n">timedelta</span><span class="p">(</span><span class="n">seconds</span><span class="o">=</span><span class="n">seconds</span><span class="p">)</span>
            <span class="n">fut</span><span class="o">.</span><span class="n">output_txt_file</span><span class="p">(</span><span class="n">shift_timestamps</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">standard</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">out_dir</span><span class="o">=</span><span class="n">out_dir</span><span class="p">,</span> <span class="n">out_file</span><span class="o">=</span><span class="n">f</span><span class="p">)</span>
        <span class="k">except</span> <span class="n">pd</span><span class="o">.</span><span class="n">errors</span><span class="o">.</span><span class="n">EmptyDataError</span><span class="p">:</span>
            <span class="k">pass</span>

        <span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="n">traceback</span><span class="o">.</span><span class="n">format_exc</span><span class="p">())</span>
            <span class="k">pass</span>

        <span class="n">counter</span> <span class="o">+=</span> <span class="mi">1</span></div>
</pre></div>

           </div>
           
          </div>
          <footer>

  <hr/>

  <div role="contentinfo">
    <p>
        &#169; Copyright 2020, NRG Systems, Technical Services.

    </p>
  </div>
    
    
    
    Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
    
    <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
    
    provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>